home *** CD-ROM | disk | FTP | other *** search
/ PC Users 1998 January / Cd Pc Users extra 16 enero 1999.iso / prog / inst / dynmenu / form1.frm (.txt) next >
Encoding:
Visual Basic Form  |  1998-11-27  |  2.9 KB  |  99 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "Dynamic Menu"
  5.    ClientHeight    =   1455
  6.    ClientLeft      =   2265
  7.    ClientTop       =   3045
  8.    ClientWidth     =   3165
  9.    LinkTopic       =   "Form1"
  10.    MaxButton       =   0   'False
  11.    MinButton       =   0   'False
  12.    PaletteMode     =   1  'UseZOrder
  13.    ScaleHeight     =   1455
  14.    ScaleWidth      =   3165
  15.    Begin VB.CommandButton CmdRemove 
  16.       Cancel          =   -1  'True
  17.       Caption         =   "Remove"
  18.       Height          =   495
  19.       Left            =   1800
  20.       TabIndex        =   3
  21.       Top             =   720
  22.       Width           =   1215
  23.    End
  24.    Begin VB.CommandButton CmdAdd 
  25.       Caption         =   "Add"
  26.       Default         =   -1  'True
  27.       Height          =   495
  28.       Left            =   240
  29.       TabIndex        =   2
  30.       Top             =   720
  31.       Width           =   1215
  32.    End
  33.    Begin VB.TextBox CaptionText 
  34.       Height          =   285
  35.       Left            =   840
  36.       TabIndex        =   1
  37.       Top             =   240
  38.       Width           =   2175
  39.    End
  40.    Begin VB.Label Label1 
  41.       Caption         =   "Caption"
  42.       Height          =   255
  43.       Left            =   240
  44.       TabIndex        =   0
  45.       Top             =   240
  46.       Width           =   615
  47.    End
  48.    Begin VB.Menu mnuFile 
  49.       Caption         =   "&File"
  50.       Begin VB.Menu mnuFileList 
  51.          Caption         =   "mnuFileList"
  52.          Index           =   0
  53.          Visible         =   0   'False
  54.       End
  55.       Begin VB.Menu mnuFileSep 
  56.          Caption         =   "-"
  57.          Visible         =   0   'False
  58.       End
  59.       Begin VB.Menu mnuFileExit 
  60.          Caption         =   "E&xit"
  61.       End
  62.    End
  63. Attribute VB_Name = "Form1"
  64. Attribute VB_GlobalNameSpace = False
  65. Attribute VB_Creatable = False
  66. Attribute VB_PredeclaredId = True
  67. Attribute VB_Exposed = False
  68. Option Explicit
  69. Private max_index As Integer
  70. Private Sub CmdAdd_Click()
  71.     ' Load the new menu item.
  72.     max_index = max_index + 1
  73.     Load mnuFileList(max_index)
  74.     mnuFileList(max_index).Caption = CaptionText.Text
  75.     mnuFileList(max_index).Visible = True
  76.     CaptionText.Text = ""
  77.     ' Make the separator visible.
  78.     mnuFileSep.Visible = True
  79. End Sub
  80. Private Sub CmdRemove_Click()
  81. Dim txt As String
  82. Dim ctl As Menu
  83.     ' Find the menu item with this caption.
  84.     txt = CaptionText.Text
  85.     CaptionText.Text = ""
  86.     For Each ctl In mnuFileList
  87.         If ctl.Caption = txt Then Unload ctl
  88.     Next ctl
  89.     ' Make the separator visible.
  90.     If mnuFileList.Count < 2 Then _
  91.         mnuFileSep.Visible = False
  92. End Sub
  93. Private Sub mnuFileExit_Click()
  94.     Unload Me
  95. End Sub
  96. Private Sub mnuFileList_Click(Index As Integer)
  97.     MsgBox "Selected item" & Str$(Index)
  98. End Sub
  99.